﻿using System;
using UnityEngine;

public enum E_GOAPAction
{
	invalid = -1,

	// === 基础移动类 ===
	move,                   //移动
	gotoPos,                //移动到目标位置（优先级70）
	gotoMeleeRange,         //移动到近战范围（优先级70）

	// === 战斗移动类 ===
	combatMoveRight,        //战斗中右移
	combatMoveLeft,         //战斗中左移
	combatMoveForward,      //战斗中前移
	combatMoveBackward,     //战斗中后退
	combatRunForward,       //战斗中奔跑向前
	combatRunBackward,      //战斗中奔跑后退

	// === 面向、武器相关 ===
	lookatTarget,           //注视目标（优先级95）
	weaponShow,             //显示/拔出武器（优先级90）
	weaponHide,             //收起武器

	// === 攻击类 ===
	attackMeleeOnce,        //普通近战攻击
	attackWhirl,            //旋风斩
	attackBerserk,          //狂暴连击
	attackMeleeTwoSwords,   //双刀攻击
	attackBow,              //弓箭攻击
	attackBoss,             //Boss专用攻击（优先级20）
	attackRoll,             //翻滚攻击（优先级20）
	attackCounter,          //反击攻击（优先级20）

	// === 指令类 ===
	orderAttack,            //指令：攻击
	orderDodge,             //指令：闪避
	rollToTarget,           //向目标翻滚（优先级80）

	// === 互动类 ===
	useLever,               //使用机关（拉杆等）
	playAnim,               //播放剧情动画

	// === 受击/死亡类 ===
	injury,                 //受伤（优先级100）
	injuryOrochi,           //特定受伤（大蛇等BOSS？）（优先级100）
	death,                  //死亡（优先级100）
	block,                  //格挡（优先级50）
	tount,                  //嘲讽（吸引仇恨）  
	knockdown,              //倒地（优先级100）

	// === 特殊行为 ===
	teleport,               //瞬移（优先级90）
	count
}

class GOAPActionFactory : System.Object
{
	public static GOAPAction Create(E_GOAPAction type, Agent owner)
	{
		GOAPAction a;
		switch (type)
		{
            case E_GOAPAction.move:
                a = new GOAPActionMove(owner);
                break;
            case E_GOAPAction.gotoPos:
			    a = new GOAPActionGoTo(owner);
                break;
            case E_GOAPAction.combatMoveRight:
                a = new GOAPActionCombatMoveToRight(owner);
                break;
            case E_GOAPAction.combatMoveLeft:
                a = new GOAPActionCombatMoveToLeft(owner);
                break;
            case E_GOAPAction.combatMoveForward:
                a = new GOAPActionCombatMoveForward(owner);
                break;
            case E_GOAPAction.combatMoveBackward:
                a = new GOAPActionCombatMoveBackward(owner);
                break;
            case E_GOAPAction.combatRunForward:
                a = new GOAPActionCombatRunForward(owner);
                break;
            case E_GOAPAction.combatRunBackward:
                a = new GOAPActionCombatRunBackward(owner);
                break;
            case E_GOAPAction.lookatTarget:
                a = new GOAPActionLookAtTarget(owner);
                break;
            case E_GOAPAction.gotoMeleeRange:
                a = new GOAPActionGoToMeleeRange(owner);
                break;
            case E_GOAPAction.weaponShow:
			    a = new GOAPActionWeaponShow(owner);
			    break;
            case E_GOAPAction.weaponHide:
                a = new GOAPActionWeaponHide(owner);
                break;
            case E_GOAPAction.attackMeleeOnce:
			    a = new GOAPActionAttackMeleeOnce(owner);
			    break;
            case E_GOAPAction.attackBerserk:
                a = new GOAPActionAttackBerserk(owner);
                break;
            case E_GOAPAction.attackWhirl:
                a = new GOAPActionAttackWhirl(owner);
                break;
            case E_GOAPAction.attackCounter:
                a = new GOAPActionAttackCounter(owner);
                break;
            case E_GOAPAction.attackMeleeTwoSwords:
                a = new GOAPActionAttackMeleeTwoSwords(owner);
                break;
            case E_GOAPAction.attackBow:
                a = new GOAPActionAttackBow(owner);
                break;
            case E_GOAPAction.orderAttack:
                a = new GOAPActionOrderAttack(owner);
                break;
            case E_GOAPAction.attackBoss:
                a = new GOAPActionAttackBossSpecial(owner);
                break;
            case E_GOAPAction.attackRoll:
                a = new GOAPActionAttackRoll(owner);
                break;
            case E_GOAPAction.orderDodge:
                a = new GOAPActioOrderDodge(owner);
                break;
            case E_GOAPAction.rollToTarget:
                a = new GOAPActionRollToTarget(owner);
                break;
            case E_GOAPAction.useLever:
                a = new GOAPActionUseLever(owner);
                break;
            case E_GOAPAction.playAnim:
                a = new GOAPActionPlayAnim(owner);
                break;
            case E_GOAPAction.injury:
                a = new GOAPActionInjury(owner);
                break;
            case E_GOAPAction.injuryOrochi:
                a = new GOAPActionInjuryOrochi(owner);
                break;
            case E_GOAPAction.death:
                a = new GOAPActionDeath(owner);
                break;
            case E_GOAPAction.block:
                a = new GOAPActionBlock(owner);
                break;
            case E_GOAPAction.tount:
                a = new GOAPActionIdleActionTount(owner);
                break;
            case E_GOAPAction.knockdown:
                a = new GOAPActionKnockdown(owner);
                break;
            case E_GOAPAction.teleport:
                a = new GOAPActionTeleport(owner);
                break;
            default:
                Debug.LogError("GOAPActionFactory -  unknow state " + type);
			    return null;
		}

		a.InitAction();
		return a;
	}
}
